home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2006 May / PCpro_2006_05.ISO / files / mobile / fma-2.0-stable-setup.exe / {app} / sframework / plugins / FrameworkMainMenu.vbs < prev    next >
Encoding:
Text File  |  2004-09-09  |  2.1 KB  |  85 lines

  1. 'FMA Script Framework Core Plugin
  2. 'MainMenu
  3. 'The main menu that is shown as root menu
  4.  
  5. 'TODO:
  6. '-nothing atm. does what it should
  7.  
  8. Class FrameworkMainMenu
  9.     
  10.     Private List
  11.     Private m_Self
  12.     Private mainMenu
  13.     
  14.     'Some info about the plugin
  15.     Public Property Get SHOWABLE 'Do I have a menu?
  16.         SHOWABLE    = False 'This will prevent from adding myself to my plugin list
  17.     End Property
  18.     Public Property Get TITLE 'What's my name?
  19.         TITLE       = "Main Menu"
  20.     End Property
  21.     Public Property Get DESCRIPTION 'What's my purpose?
  22.         DESCRIPTION = "Shows a list of all loaded and showable plugin"
  23.     End Property
  24.     Public Property Get AUTHOR 'Who created me?
  25.         AUTHOR      = "dVrVm"
  26.     End Property
  27.     Public Property Get URL 'Were can I be found? Where can you get more information?
  28.         URL = "http://fma.xinium.com/"
  29.     End Property
  30.     
  31.     Public Property Let Self (s)
  32.         m_Self = s
  33.         Set List = New LinkedList
  34.         EventManager.RegisterEvent "AMRoot", s & ".Show", Me
  35.         Set mainMenu = New ManagedMenu
  36.         mainMenu.Title = "Main Menu"
  37.     End Property
  38.     Public Property Get Self
  39.         Self = m_Self
  40.     End Property
  41.     
  42.     Sub Show()
  43.         Dim pluginList, menuList, bi, it, comp
  44.         Set comp = New PluginTitleComparator
  45.         Set pluginList = PluginManager.GetLoadedPluginsLinkedList
  46.         QuickSorter.ComparatorSortLL pluginList, comp
  47.         Set menuList = New LinkedList
  48.         
  49.         bi = menuList.BackInserter
  50.         it = pluginList.Begin
  51.         'Add showable plugins with their title and show method
  52.         Do Until it.Object Is pluginList.Last.Object
  53.             If PluginManager(it.Item).SHOWABLE Then
  54.                 bi.Item = Array(PluginManager(it.Item).TITLE, "PluginManager(""" & it.Item & """).Show")
  55.                 Debug.DebugMsg "MainMenu added: " & it.Item
  56.             Else
  57.                 Debug.DebugMsg "MainMenu not added: " & it.Item
  58.             End If
  59.             it.iterate()
  60.         Loop
  61.         
  62.         mainMenu.SetList menuList
  63.         mainMenu.ShowMenu
  64.     End Sub
  65.     
  66. End Class
  67.  
  68. Class PluginTitleComparator
  69.     Public Function Compare( ByRef p1, ByRef p2 )
  70.         Dim a, b
  71.         a = PluginManager(p1).TITLE
  72.         b = PluginManager(p2).TITLE
  73.         a = LCase(a)
  74.         b = LCase(b)
  75.         If a = b Then
  76.             Compare = 0
  77.         ElseIf a < b Then
  78.             Compare = -1
  79.         Else
  80.             Compare = 1
  81.         End If
  82.     End Function
  83. End Class
  84.  
  85.